<?php

use Lg\View\CssBlock;
use Lg\View\JsBlock;
use Lg\View\Asset;

CssBlock::begin();
?>
<style>
    @import url("<?php echo root_url('/assets/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css'); ?>");
    @import url("<?php echo root_url('/assets/jquery-upload-file/css/uploadfile.css'); ?>");
</style>
<?php CssBlock::end(); ?>
<?php echo get_header(); ?>
<form class="form-horizontal" action="" method="post">

    <div class="row">
        <div class="col-md-12">
            <ul class="nav nav-tabs" role="tablist"> 
                <li class="nav-item"><a href="#settings" class="nav-link active" data-toggle="tab" aria-expanded="true">个人信息</a></li>
                <li class="nav-item" ><a href="#account" class="nav-link" data-toggle="tab" aria-expanded="false">账户信息</a></li>
            </ul>

            <div class="tab-content widget-content padding-md">            
                <div class="tab-pane active" id="settings">
                    <div class="form-group row <?php echo value_condition(form_has_error('user.display_name'),'has-danger'); ?>">
                        <label for="display_name" class="col-sm-2 control-label">昵称</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="user[display_name]" id="display_name" placeholder="昵称" value="<?php echo $user->display_name; ?>">
                            <span class="help-block text-danger"><?php echo form_error('user.display_name'); ?></span>
                        </div>
                    </div>
                    <div class="form-group  row">
                        <label for="first_name" class="col-sm-2 control-label">名字</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="user_profile[first_name]" id="first_name" placeholder="名字" value="<?php echo $user_profile->first_name; ?>">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="last_name" class="col-sm-2 control-label">姓氏</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="user_profile[last_name]" id="last_name" placeholder="姓氏" value="<?php echo $user_profile->last_name; ?>">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 control-label">性别</label>
                        <div class="col-sm-10 ">    
                            <label class="label-radio inline">
                                <input type="radio" name="user_profile[sex]" id="sex1"  value="1" checked />
                                <span class="custom-radio"></span>
                                男
                            </label>
                            <label class="label-radio inline">
                                <input type="radio" name="user_profile[sex]" id="sex2" value="1" <?php echo $user_profile->sex ? 'checked' : ''; ?>>
                                <span class="custom-radio"></span>女
                            </label>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="birthday" class="col-sm-2 control-label">生日</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="user_profile[birthday]" id="birthday" placeholder="生日" value="<?php echo $user_profile->birthday; ?>">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="company" class="col-sm-2 control-label">公司</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="user_profile[company]" id="company" placeholder="公司" value="<?php echo $user_profile->company; ?>">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="job_title" class="col-sm-2 control-label">职位</label>

                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="user_profile[job_title]" id="job_title" placeholder="职位" value="<?php echo $user_profile->job_title; ?>">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="about" class="col-sm-2 control-label">简介</label>

                        <div class="col-sm-10">
                            <textarea class="form-control" name="user_profile[about]" id="about" placeholder="简介"><?php echo $user_profile->about; ?></textarea>
                        </div>
                    </div>

                    <div class="form-group row">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-danger">保存</button>
                        </div>
                    </div>

                </div>
                <!-- /.tab-pane -->
                <div class="tab-pane" id="account">
                        <div class="form-group row">
                            <label for="username" class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="username" id="username" placeholder="请输入用户名" value="<?php echo $user->username; ?>">
                                <span class="help-block text-danger"><?php echo form_error('username'); ?></span>                                    
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="email" class="col-sm-2 control-label">Email</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="email" id="email" placeholder="请输入Email" value="<?php echo $user->email; ?>">
                                <span class="help-block text-danger"><?php echo form_error('email'); ?></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="password" class="col-sm-2 control-label">密码</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="password" id="password" placeholder="请输入密码" value="">
                                <span class="help-block text-danger"><?php echo form_error('password'); ?></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="repassword" class="col-sm-2 control-label">确认密码</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="repassword" id="repassword" placeholder="请再次输入密码" value="">
                                <span class="help-block text-danger"><?php echo form_error('repassword'); ?></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-danger">保存</button>
                            </div>
                        </div>
                    </div>
                
            </div>
            <!-- /.tab-content -->
        </div><!-- col-md-12 end -->
    </div>
    <!-- /.row -->   

</form>
<?php
Asset::addJs(root_url('/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'), Asset::BODY_END);
Asset::addJs(root_url('/assets/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js'), Asset::BODY_END);
Asset::addJs('//cdn.bootcss.com/jquery.form/3.51/jquery.form.min.js', Asset::BODY_END);
Asset::addJs(root_url('/assets/jquery-upload-file/js/jquery.uploadfile.min.js'), Asset::BODY_END);
JsBlock::begin(Asset::BODY_END);
?>
<script type="text/javascript">
    $(function () {
        $('#birthday').datetimepicker({
            initialDate: "1990-01-01",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            minView: 2,
            autoclose: true
        });
        $("#fileuploader").uploadFile({
            url: "<?php echo url_for('/users/?action=avatar'); ?>",
            multiple: false,
            maxFileCount: 1,
            fileName: "avatar_file",
            allowedTypes: "jpg,png,gif",
            uploadStr: "选择头像",
            abortStr: "取消上传",
            cancelStr: "取消",
            deletelStr: "删除",
            doneStr: "完成",
            dragDropStr: "<span><b>拖动文件到这里.</b></span>",
            multiDragErrorStr: "不支持多文件上传.",
            extErrorStr: "不支持的扩展: ",
            duplicateErrorStr: "文件已存在.",
            sizeErrorStr: "超出最大尺寸: ",
            uploadErrorStr: "不允许上传",
            maxFileCountErrorStr: " 超出最大文件上传数量:",
            downloadStr: "下载",
            customErrorKeyStr: "jquery-upload-file-error",
            onSuccess: function (files, data, xhr, pd)
            {
                console.log(files);
                console.log(data);
                console.log(xhr);
                console.log(pd);
                //files: list of files
                //data: response from server
                //xhr : jquer xhr object
            }
        });
    });
</script>
<?php JsBlock::end(); ?>
<?php echo get_footer(); ?>
